﻿using de.wolfmarco.pas.Shared.Database;
using de.wolfmarco.pas.Shared.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace de.wolfmarco.pas.Accounting.Database
{
    /// <summary>Geplanter Geldfluss (geplante Einnahmen/Ausgaben bzw. Fixkosten)</summary>
    public class ScheduledCashFlow : EntityBase
    {
        #region NotMapped Fields

        [NotMapped]
        public static readonly string DirectionProperty = "Direction";
        [NotMapped]
        public static readonly string AmountOfMoneyProperty = "AmountOfMoney";
        [NotMapped]
        public static readonly string LoopProperty = "Loop";
        [NotMapped]
        public static readonly string RhythmProperty = "Rhythm";
        [NotMapped]
        public static readonly string StartDateProperty = "StartDate";
        [NotMapped]
        public static readonly string EndDateProperty = "EndDate";
        [NotMapped]
        public static readonly string DescriptionProperty = "Description";

        #endregion NotMapped Fields

        private CashFlowDirectionEnum direction;
        /// <summary>Richtung des Geldflusses. Einnahme oder Ausgabe?</summary>
        public CashFlowDirectionEnum Direction
        {
            get { return direction; }
            set
            {
                direction = value;
                RaisePropertyChanged(ScheduledCashFlow.DirectionProperty);
            }
        }

        private decimal amountOfMoney;
        /// <summary>Geldbetrag. Immer positiver Wert (Betrag), da die Richtung über das Feld Direction angegeben wird.</summary>
        public decimal AmountOfMoney
        {
            get { return amountOfMoney; }
            set
            {
                amountOfMoney = value;
                RaisePropertyChanged(ScheduledCashFlow.AmountOfMoneyProperty);
            }
        }

        private CashFlowLoopEnum loop;
        /// <summary>Wiederholung des Geldflusses. Keine, Wöchentlich, Täglich, etc.</summary>
        public CashFlowLoopEnum Loop
        {
            get { return loop; }
            set
            {
                loop = value;
                RaisePropertyChanged(ScheduledCashFlow.LoopProperty);
            }
        }

        private CashFlowRhythmEnum rhythm;
        /// <summary>Rhythmus ab Stichtag (StartDate), Anfang des Monats, Mitte des Monats, Ende des Monats, etc.</summary>
        public CashFlowRhythmEnum Rhythm
        {
            get { return rhythm; }
            set
            {
                rhythm = value;
                RaisePropertyChanged(ScheduledCashFlow.RhythmProperty);
            }
        }

        private DateTime startDate;
        /// <summary>Keine Wiederholung? Dann fixer Zeitpunkt, Mit Wiederholungen? Dann Startzeitpunk</summary>
        public DateTime StartDate
        {
            get { return startDate; }
            set
            {
                startDate = value;
                RaisePropertyChanged(ScheduledCashFlow.StartDateProperty);
            }
        }

        private DateTime? endDate;
        /// <summary>Endzeitpunkt der Wiederholungen. NULL = Endlos bzw. noch unbekannt</summary>
        public DateTime? EndDate
        {
            get { return endDate; }
            set
            {
                endDate = value;
                RaisePropertyChanged(ScheduledCashFlow.EndDateProperty);
            }
        }

        private String description;
        /// <summary>Beschreibung des geplanten Geldflusses</summary>
        [MaxLength(200)]
        public String Description
        {
            get { return description; }
            set
            {
                description = value;
                RaisePropertyChanged(ScheduledCashFlow.DescriptionProperty);
            }
        }
    }
}
